#include "lvgl_app/hal_Exp/hal_Exp.h"



static void lv_pm_1s_handler(lv_timer_t* tmr)
{
    /*向lvgl发送时间数据*/
    extern Myos_MessageInterface  *User_MessageInterface;                       //系统数据信息接口
    lv_pm_rtc_def lv_pm_rtc_val;
    lv_pm_rtc_val.Year = User_MessageInterface->Myos_time->year;
    lv_pm_rtc_val.Mon = User_MessageInterface->Myos_time->mon;
    lv_pm_rtc_val.Day = User_MessageInterface->Myos_time->day;
    lv_pm_rtc_val.Hour = User_MessageInterface->Myos_time->hour;
    lv_pm_rtc_val.Min = User_MessageInterface->Myos_time->min;
    lv_pm_rtc_val.Sec = User_MessageInterface->Myos_time->sec;
    lv_msg_send(PAGE_BAR_RTC, &lv_pm_rtc_val);
    
    /*向lvgl发送电量数据*/
    int8_t Power  = OS_GetSystemPower();
    lv_msg_send(PAGE_BAR_BAT, &Power);
    
    /*向lvgl发送剩余内存信息*/
    unsigned pointer Free_Ram = OS_GetInlineSysmemory();
    lv_msg_send(PAGE_BAR_RAM, &Free_Ram);
    
    /*向lvgl发送USB连接状态*/
    extern unsigned int32 *usb_sof_cnt;                                         //USB的SOF计数
    static unsigned int32 usb_sof_cnt_tmp = 0;
    int8_t quantity;
    if( usb_sof_cnt_tmp  != *usb_sof_cnt )
    {
        usb_sof_cnt_tmp  = *usb_sof_cnt;
        quantity = 1;
    }
    else
    {
       quantity = 0;
    }
    lv_msg_send(PAGE_BAR_USB, &quantity);
}

void lv_pm_hal_Exp_in_init(void)
{
    lv_timer_create(lv_pm_1s_handler, 1000,NULL);
}
